package com.asset.service.impl;

import com.asset.mapper.UserMapper;
import com.asset.model.entity.User;
import com.asset.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImpl  implements UserService {
    @Autowired
    private UserMapper userDao;

    public User login(String loginName, String password) {

        User user = userDao.selectByUserName(loginName);
        
        // 调试日志
        System.out.println(user + "hello");
        
        if (user == null) {
            String errorMsg = "登录名 不存在";
            System.err.println(errorMsg);
//            throw new RuntimeException(errorMsg);
            return user;
        }
        
        if (password.equals(user.getPassword())) {
            return user;
        }else{
            String errorMsg = "密码错误";
            System.err.println(errorMsg);
            return null;
        }



    }
}
